﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using App.Common;
public class NormalBullet : BulletBase
{
    public string Explode = "Flame1";

    public override void Update()
    {
        base.Update();
        BulletControl();
    }
    public override void OnEnable()
    {
        base.OnEnable();
        if (GetComponent<TrailRenderer>() != null)
        {
            GetComponent<TrailRenderer>().Clear();
            GetComponent<TrailRenderer>().enabled = false;
            GetComponent<TrailRenderer>().enabled = true;
        }
    }
    private void BulletControl()
    {
        if (GetComponent<TrailRenderer>() != null)
        {
            GetComponent<TrailRenderer>().startColor = GetAttrColor();
        }
    }


    public override void OnOutofRange()
    {
        HitOthersEffect(transform.position);
        base.OnOutofRange();
    }
    public override void OnHitOthers(GameObject other)
    {
        base.OnHitOthers(other);
        if (other.GetComponent<MonoBase>() != null)
        {
            other.GetComponent<MonoBase>().LastTimeMove(bulletBase.Direction, bulletBase.Speed / 2, 6,()=> { });
        }
    }
    public override void OnBounced()
    {
        base.OnBounced();
    }
    public override void OnDestroyed()
    {
        base.OnDestroyed();
        Destoyed();
    }
    public override void HitNoneMono()
    {
        if (Explode != "")
        {
            GameMgr.Get<IBuffManager>().Explosion(bulletBase.attribute, transform.position, Explode);
        }
        base.HitNoneMono();
    }
    private void Destoyed()
    {
        GameMgr.Get<IBulletManager>().RemoveMono(gameObject.name);
    }
}
